<%--
 *  File:    ApprovalUserGroupDetail.jsp
 *  @Author: Saraxia 
 *  Date:    2012/11/07
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.ApprovalUserGroupDetail"); 
%>

<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "UPM";
	String privilegeCode = "Z0101,L402";
	String contextPath = request.getContextPath();
%>



<%
  	Integer nUserGroupId = null;
  	if(request.getParameter("zylmdapprovalgroupid") != null)
    	nUserGroupId = new Integer((String)request.getParameter("zylmdapprovalgroupid"));
  	else
    	nUserGroupId = (Integer)session.getAttribute("zylmdapprovalgroupid");
  	session.setAttribute("zylmdapprovalgroupid",nUserGroupId);
  	
%>

<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>

<html>
<head>
<title>ApprovalUserGroupDetail</title>
<PageFlow:CheckPageFlow pageName="instanceusergroupdetail"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector userGroupDetail = (Vector)pageContext.getAttribute("usergroupdetail");
  	if(userGroupDetail == null)
  	{
    	userGroupDetail = new Vector();
  	}
  	Vector allUsers = (Vector)pageContext.getAttribute("alluser");
  	if(allUsers == null)
  	{
    	allUsers = new Vector();
  	}
  
  	String strUserGroupName = (String)((HashMap)pageContext.getAttribute("usergroup")).get("mdapprovalgroupname");
  
  	//get current usergroupinfo
  	boolean bIsEveryone = false;
  	boolean bIsAdministrator = false;  
  	if(strUserGroupName.equalsIgnoreCase("everyone"))
    	bIsEveryone = true;
  	if(strUserGroupName.equalsIgnoreCase("administrator")) 
    	bIsAdministrator = true; 
  
  	//get current userinfo
  	HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");
  	String isPrimaryAdmin = (String)CurUserInfo.get("isprimaryadmin");
  	if(isPrimaryAdmin == null)
  	{
    	isPrimaryAdmin = "";
  	}
  	String strCurUserName = (String)CurUserInfo.get("username");
  	if(strCurUserName == null)
  	{
    	strCurUserName = "";
  	} 
  	//give permission
  	boolean bCanUpdate = true;
  	if(bIsEveryone)
  	{
		bCanUpdate = false;
  	}
  	if(bIsAdministrator && !isPrimaryAdmin.equalsIgnoreCase("Y"))
  	{
	    bCanUpdate = false;
  	}               
%>

<script>
function page_add()
{
  employeename = document.usergroupdetailform.employeename.value
  if( employeename== "" || employeename==null)alert("<%= label.getLabelName("L_NoUserSame") %>");
  document.usergroupdetailform.actionname.value = "add";
  isRunning = true;
  document.usergroupdetailform.submit();
}
function page_delete()
{
  if(nullChecked(document.usergroupdetailform.usergroupuserlinkids,document.usergroupdetailform.rowcount.value))
  {
    alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
    return;
  }
  if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>"))
    return;
  document.usergroupdetailform.actionname.value = "delete";
  isRunning = true;
  document.usergroupdetailform.submit();
}
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(usergroupdetailform,actionvalue,orderbyname);
  editform.action = "ApprovalUserGroupDetail.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();  
}
var popwindow;
function popEmployee(){
	if(popwindow!=null) popwindow.close();	
	usergroupid = document.usergroupdetailform.zylmdapprovalgroupid.value;
    url = '<%=contextPath%>/zylapprv/approval/ApprovalContactSummaryForPop.jsp?flag=1&zylmdapprovalgroupid='+usergroupid+'&<%= OvalTools.randomURL() %>';
    attribute = 'height=300, width=500,top=100,left=100,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no';
	popwindow = window.open(url,'newwindow', attribute);
}
function setContact(contactid,username,contactname){
	document.usergroupdetailform.userid.value=contactid;
	document.usergroupdetailform.employeename.value=contactname;
}
</script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">


	<table width="100%" cellspacing="0" cellpadding="0">
	
	<% //--------------------------------------  hidden form variant --%>
  	<form name="usergroupdetailform" method="post" action="../../Dispatcher">
  	<input type="hidden" name="pagename" value="instanceusergroupdetail">
  	<input type="hidden" name="actionname">  
  	<input type="hidden" name="zylmdapprovalgroupid" value = "<%=JspHelper.filterNull( nUserGroupId )%>"> 
  	<input type="hidden" name="mdapprovalgroupname" value = "<%=JspHelper.filterNull( strUserGroupName )%>"> 
    <input type="hidden" name="theendindex" value="<%=JspHelper.filterNull( nCurEndIndex )%>">
  	<input type="hidden" name="maxitem" value="<%=JspHelper.filterNull( nCurMaxItem )%>">
  	<input type="hidden" name="pageaction">
  	<input type="hidden" name="orderbycolumn" value="<%=JspHelper.filterNull( strCurOrderByCol )%>">
  	<input type="hidden" name="orderbytype" value="<%=JspHelper.filterNull( strCurOrderByType )%>">
  	<input type="hidden" name="totalpage" value="<%=JspHelper.filterNull( nCurTotalPage )%>">   
  	<input type="hidden" name="rowcount" value="<%=JspHelper.filterNull( nCurRowCount )%>">            
          
    <tr> 
    	<td valign="top"> 
    		
    		<% //--------------------------------------  header --%>
        	<table width="100%" cellspacing="0" cellpadding="0">
          	<tr> 
            	<td class="summary_top"></td>
          	</tr>
        	</table>
        	<img src="../../images/<%= strLanguageCode %>/quote.gif"><%= label.getLabelName("L_UserGroupName") + label.getLabelName("L_Colon") %>  <%=JspHelper.filterNull( strUserGroupName )%> <br>
        	
        	<table border="1" cellpadding="0" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="center" width="100%">
          	<% //--------------------------------------  summary header --%>
          	<tr class="deepblue-left"> 
            	<td width="5%" class="title_center">&nbsp;</td>
            	<td width="24%" class="title_center">&nbsp;<a href="javascript:page_summary('orderby','username')"><%= label.getLabelName("L_UserName") %></a></td>
            	<td width="15%" class="title_center">&nbsp;<a href="javascript:page_summary('orderby','passwordstartdate')"><%= label.getLabelName("L_EmployeeCode1") %></a></td>
            	<td width="13%" class="title_center">&nbsp;<a href="javascript:page_summary('orderby','employeename')"><%= label.getLabelName("L_EmployeeName") %></a></td>
            	<td width="16%" class="title_center">&nbsp;<a href="javascript:page_summary('orderby','passwordexpiredate')"><%= label.getLabelName("L_Department") %></a></td>
            	<td class="title_center">&nbsp;<a href="javascript:page_summary('orderby','email')"><%= label.getLabelName("L_TitleName") %></a></td>
          	</tr>
          	
          	<% //--------------------------------------  loop results --%>
          	<%
            	int i = 0;
            	String strClassType = new String();
          	%>
            <logic:iterate id="usergroupdetail" collection="<%= userGroupDetail %>">   
          	<%
            	HashMap detailMap = (HashMap)pageContext.getAttribute("usergroupdetail");  
            	String un = (String)detailMap.get("username");
            	boolean bCanDelete = true;
            	if(bIsAdministrator && un.equalsIgnoreCase(strCurUserName))     
            	{ 
              		bCanDelete = false;
            	}
            	if(i%2 == 1){
              		strClassType = "td-listrom";
            	}else{                    
              		strClassType = "";
            	}   
            	i++;	        
          	%> 
                   
          	<tr>
            	<td width="5%" class="<%=JspHelper.filterNull( strClassType )%>"> &nbsp;
          		<%if(bCanUpdate && bCanDelete){%>
              		<input type="checkbox" name="usergroupuserlinkids" value="<%=JspHelper.filterNull( detailMap.get("zylmdapprovalgroupdetailid") )%>" class="normalradio">
          		<%}else{%>
              		<input type="checkbox" name="usergroupuserlinkids" Disabled value="<%=JspHelper.filterNull( detailMap.get("zylmdapprovalgroupdetailid") )%>" class="normalradio">            
          		<%}%> 
            	</td>
            	<td  width="24%" class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( detailMap.get("username") )%></td>
            	<td  width="13%" class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( detailMap.get("employeecode") )%></td>
            	<td  width="15%" class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( detailMap.get("employeename") )%></td>
            	<td  width="16%" class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<%=JspHelper.filterNull( detailMap.get("deptname") )%></td>
            	<td  width="16%" class="<%=JspHelper.filterNull( strClassType )%>">&nbsp;<custom:write property="jobtitlecode"  dictType="JobTitle" nbsp="true" name="usergroupdetail"  /></td>
          	</tr>
          	</logic:iterate>
          	
          	<tr> 
            	<td colspan="7"> 
              		<table width="100%" cellspacing="0" border="0">
                	<tr> 
                  		<td height="19" width="300"> 
                  		
							<custom:hidden name="onerow" property="userid"/>
							<custom:text name="onerow" property="employeename" readonly="true" size="6"/>
							<a onclick="popEmployee()"><custom:button type="3" value="*"/></a>
                  		</td>                  
                  		<td height="19" width="240"><a onclick="page_add()"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a></td>
                 		<td height="19" width="53"><% if(nCurPageNo.intValue() > 1){ %><a href="javascript:page_summary('first')"><span class="td_right"><img src="../../images/<%= strLanguageCode %>/first.gif" style="border: 0 solid #000000" border="0"></span></a> <%}%>
                    <% if(bCurHasPre){ %><span class="td_right"><a href="javascript:page_summary('pre')"><img src="../../images/<%= strLanguageCode %>/Pre.gif" border="0" style="border: 0 solid #000000"></a></span><%}%></td>
                  <td height="19" class="td_right" width="40"><%= label.getLabelName("L_Number") + " "%></td>
                  <td height="19" class="td_center" width="32"> 
                    <input type="text" name="jumptemp" size="3" value="<%=JspHelper.filterNull( nCurPageNo )%>" onblur="javascript:jumppage.value = jumptemp.value;">
                    <input type="hidden" name="jumppage" size="3" value="<%=JspHelper.filterNull( nCurPageNo )%>">
                  </td>
                  <td height="19" width="17"><%= " " + label.getLabelName("L_Page") %></td>
                  <td height="19" width="43"> <a href="javascript:page_summary('jumppage')"><img src="../../images/<%= strLanguageCode %>/go_fy.gif" width="25" height="12" border="0"></a></td>
                  <td height="19" class="td_center" width="51"><%= label.getLabelName("L_Total") + " "%> <%=JspHelper.filterNull( nCurTotalPage )%> <%= " " + label.getLabelName("L_Page") %></td>
                  <td height="19" class="td_right" width="81"> 
                    <% if(bCurHasNext){ %><a href="javascript:page_summary('next')"><img src="../../images/<%= strLanguageCode %>/next.gif" style="border: 0 solid #000000" border="0"></a><%}%> 
                    <% if(nCurPageNo.intValue() < nCurTotalPage.intValue()){ %><a href="javascript:page_summary('last')"><img src="../../images/<%= strLanguageCode %>/last.gif" style="border: 0 solid #000000" border="0"></a><%}%>&nbsp;&nbsp; 
                  </td>
                	</tr>
              		</table>
            	</td>
          	</tr>
        	</table>
      </td>
 	</tr>
    <tr> 
    	<td class="summary_top"></td>
    </tr>
    
    <% //--------------------------------------  page operation button --%>
    <tr> 
    	<td class="td_center">
    	<% if(bCanUpdate) { %>
    		<a onclick="allChecked(usergroupdetailform)"><custom:button type="1" label="L_Saveall" imgsrc="saveall.gif" border="0" style="width:60"/></a>
    		<a onclick="allCancel(usergroupdetailform)"><custom:button type="1" label="L_Resetmarks" imgsrc="resetmarks.gif" border="0"/></a>
    		<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a> 
        <% } %>
        </td>
    </tr>
	</table>
	
</form>
</body>
</html>


